﻿<UserControl x:Class="StockholmsStad.Windows.UI.Infrastructure.Controls.DateTimePicker"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:wpftoolkit="clr-namespace:Microsoft.Windows.Controls;assembly=WPFToolkit"
    xmlns:converters="clr-namespace:StockholmsStad.Windows.UI.Infrastructure.Converters"
    MinWidth="105" Name="UC">
    <UserControl.Resources>
        <converters:DateTimeToDateString x:Key="dateTimeConverter" />
    </UserControl.Resources>
    
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*" />
            <ColumnDefinition Width="Auto" />
        </Grid.ColumnDefinitions>

        <TextBox x:Name="tbText" MaxLength="10" Height="22" Grid.Column="0"
                 Text="{Binding ElementName=UC, Path=SelectedDate, Mode=OneWay, Converter={StaticResource dateTimeConverter}}" />
       
        <Grid Grid.Column="2" Margin="2,0,0,0">
            <Image Source="../Images/calendar.png" Cursor="Hand" MouseLeftButtonDown="openPopupCalendar_Click" Width="20" Height="20" VerticalAlignment="Center" />

            <Popup x:Name="popupCalendar" PlacementRectangle="0, 0, 0 ,0" StaysOpen="False" Grid.Column="1">
                <Grid>
                    <wpftoolkit:Calendar x:Name="calendarControl" Language="sv-SE" FirstDayOfWeek="Monday" SelectedDate="{Binding ElementName=UC, Path=SelectedDate, Mode=TwoWay}" />
                </Grid>
            </Popup>
        </Grid>
    </Grid>
</UserControl>
